<template>
	<view>
		<cu-custom :isBack="true">
			<block slot="content">
				<view class="custom-title">问卷</view>
			</block>
		</cu-custom>
		<view class="padding-top-48 padding-left-32 padding-right-32">
			<view class="question-content flex">
				<view class="flex-sub text-center border-right">
					<view class="text-sm text-white">全部问卷</view>
					<view class="padding-top-xs question-num">{{total}}</view>
				</view>
				<view class="flex-sub text-center">
					<view class="text-sm text-white">待完成</view>
					<view class="padding-top-xs question-num">{{progressing-complete}}</view>
				</view>
				<view class="flex-sub text-center">
					<view class="text-sm text-white">进行中</view>
					<view class="padding-top-xs question-num">{{progressing}}</view>
				</view>
				<view class="flex-sub text-center">
					<view class="text-sm text-white">已完成</view>
					<view class="padding-top-xs question-num">{{complete}}</view>
				</view>
			</view>
			<view class="margin-top flex align-center justify-between flex-wrap">
				<view class="question-list-content" v-for="(item,index) in wenjuan" :key="index">
					<view class="title">{{item.title}}</view>
					<view class="padding-top-16">
						<image src="https://txr001.zthj.net/static/img/jd.png" class="img-28 text-img-center"></image>
						<text class="padding-left-12 text-xs text-767879 text-img-center">{{item.nickname}}</text>
					</view>
					<view class="padding-top-16">
						<image src="https://txr001.zthj.net/static/img/time.png" class="img-28 text-img-center"></image>
						<text class="padding-left-12 text-xs text-767879 text-img-center">截止时间：{{item.end_time}}</text>
					</view>
					<view v-if="item.is_join==0 &&item.is_end==1" class="input-btn-content">
						<button class="cu-btn input-btn"
							@click.stop="goPage('/pages/questionnaire/dataFilling?s_id='+item.s_id,true)">去填写</button>
					</view>
					<view v-else class="margin-top-lg flex align-center justify-center">
						<cCharts></cCharts>
					</view>
					<view v-else class="flex margin-top-42" @click="goPage('/pages/questionnaire/questionInfo',true)">
						<view class="flex-sub text-center">
							<view class="text-0101 text-40">100</view>
							<view class="text-b2b6b8 text-sm">最高分</view>
						</view>
						<view class="fg">|</view>
						<view class="flex-sub text-center">
							<view class="text-0101 text-40">631</view>
							<view class="text-b2b6b8 text-sm">排名</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import cCharts from '@/components/charts/circleCharts.vue'
	export default {
		components: {
			cCharts
		},
		data() {
			return {
				wenjuan: [],
				total: 0,
				progressing: 0,
				complete: 0
			}
		},
		onLoad() {
			this.getWenjuan();

		},
		onShow() {
			this.getTongji();
		},
		methods: {
			getWenjuan: async function() {
				let res = await this.$api.getWenjuan();
				this.wenjuan = res;
				this.total = this.wenjuan.length;
			},
			getTongji: async function() {
				let res = await this.$api.tongji();
				this.progressing = res.progressing;
				this.complete = res.complete;
				// console.log(res);
			}
		}
	}
</script>

<style scoped lang="less">
	.question-content {
		padding: 32rpx 0;
		background: #01C77A;
		border-radius: 24rpx;

		.question-num {
			font-size: 40rpx;
			font-weight: 600;
			color: #FFFFFF;
		}

		.border-right {
			border-right: 2rpx solid #FFFFFF;
		}
	}

	.question-list-content {
		width: 328rpx;
		background: #FFFFFF;
		border-radius: 48rpx;
		margin-bottom: 30rpx;
		padding: 32rpx;

		.title {
			font-size: 24rpx;
			font-weight: 600;
			color: #010101;
		}

		.input-btn-content {
			margin: 40rpx 32rpx 10rpx;

			.input-btn {
				height: 56rpx;
				line-height: 56rpx;
				background: #24458E;
				border-radius: 48rpx;
				font-size: 24rpx;
				font-weight: 500;
				color: #FFFFFF;
				width: 100%;
			}
		}

		.fg {
			margin-top: 20rpx;
			color: #D9D9D9;
			font-size: 30rpx;
		}
	}
</style>